﻿-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[GetCargo]
(	@Index int,
	@PageSize int
)
AS
BEGIN
	SELECT 
	Cargo.Cargo_ID,
	Cargo.Name,
	Cargo.Description,
	Cargo.ShortCode,
	Cargo.Code,
	CargoETSNG.Name,
	Cargo.CodeGNG,
	CargoGNG.Name,
	Cargo.Mnemocode,
	Cargo.IsUsed,
	Cargo.IsEmpty
	From 	
	(SELECT ROW_NUMBER() OVER (ORDER BY Cargo.Cargo_ID asc) as MyRowNumber, Cargo.Cargo_ID
		FROM Cargo ) as addtionalCargo
	Left Join Cargo  on addtionalCargo.Cargo_ID = Cargo.Cargo_ID
	Left Join CargoETSNG On Cargo.Code = CargoETSNG.CargoETSNG_ID
	Left Join CargoGNG On Cargo.CodeGNG = CargoGNG.CargoGNG_ID
	

	Where addtionalCargo.MyRowNumber BETWEEN  (((@Index - 1) * @PageSize )+ 1) AND @Index*@PageSize
	
END